import React from "react"

class MouseMove extends React.Component{
    // 状态数据
    state={
        x:0,
        y:0
    }
    // 修改数据的方法
    getMove=(e)=>{
        this.setState({
            x:e.clientX,
            y:e.clientY
        })
    }
    render(){
        // console.log(this.props)
        return this.props.children(this.state)
    }
    componentDidMount(){
        window.addEventListener("mousemove",this.getMove)
    }
    componentWillUnmount(){
        window.removeEventListener("mousemove",this.getMove)
    }
}

export default MouseMove